//wordcount.h
#include<string>
using namespace std;
class wordcount 
{
public:
	wordcount()
	{
		word = 0;
		sentence = 0;
		character = 0;
		text[1000] = { 0 };
	}
	void com();
	void input();
	void wc();
	void output();
private:
	int character;            
	int word;             
	int sentence;            	
	char text[1000];          	   
	char command[2];                
};
//wordcount.cpp
#include<iostream>
#include<string>
#include"wordcount.h"
void wordcount::com() 
{
	int i;
	for (i = 0; i < 2; i++)
	{
		cin >> command[i];
	}
}

void wordcount::input() 
{
	cout << "输入文本：" << endl;
	for (int i = 0; i <1000; i++)
	{
		cin >> text[i];
		character++;
		if (text[i] == '\n ')
			break;
	}
}

void wordcount::wc() 
{
	int i;
	for (i = 0; i <1000; i++) 
	{
		if((text[i]>='a'&&text[i]<='z')||(text[i]>='A'&&text[i]<='Z'))
			if(text[i+1]==' '||text[i + 1] == ',' || text[i + 1] == '.' || text[i + 1] == '!' || text[i + 1] == '?')
				word++;		
		if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')) 
			if (text[i + 1] == '.' || text[i + 1] == '!' || text[i + 1] == '?')
				sentence++;		
	}
}
void wordcount::output()
{
		if (command[1]=='c')
			cout << "文档所含字符数 : " << character<< endl;
		if (command[1]=='w')
			cout << "文档所含单词数 : " << word<< endl;
		if (command[1]=='s')
			cout << "文档所含句子数 : " << sentence << endl;
}
//main.cpp
#include<iostream>
#include"wordcount.h"
using namespace std;
int main() 
{
	wordcount project;
	project.com();
	project.input();
	project.wc();
	project.output();
	return 0;
}